package com.lg.study.redis.controller;

import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

@Api(tags = "服务测试")
@Slf4j
@RestController
@RequestMapping("/base")
public class BaseController {
    @Value("${server.port}")
    private String serverPort;

    @Autowired
    private JedisPool jedisPool;

    @Autowired
    private RedisTemplate redisTemplate;

    @GetMapping("/baseConfig")
    public String getBaseConfig(){
        return serverPort;
    }


    @GetMapping("/testRedis")
    public void testRedis(){
        Jedis jedis = jedisPool.getResource();
        jedis.select(1);
        jedis.set("aa", "\"aa\"");

        Object aa = redisTemplate.opsForValue().get("aa");

        log.info(aa.toString());

    }

}
